package org.example.seat_management.Controller.api;

import org.example.seat_management.Entity.Classroom;
import org.example.seat_management.Service.ClassroomService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/classrooms")
public class ClassroomController {

    private final ClassroomService classroomService;

    public ClassroomController(ClassroomService classroomService) {
        this.classroomService = classroomService;
    }

    @PostMapping
    public Long create(@RequestBody Classroom classroom) {
        return classroomService.create(classroom);
    }

    @PutMapping("/{id}")
    public void update(@PathVariable Long id, @RequestBody Classroom classroom) {
        classroom.setId(id);
        classroomService.update(classroom);
    }

    @GetMapping
    public List<Classroom> listAll() {
        return classroomService.listAll();
    }
}


